package optional;

import org.junit.Test;

import java.util.Optional;

/**
 * @Author Klys
 * @Date 2023/5/23 17:34
 * @Description
 * @Version 1.0
 */
public class Demo01 {

    @Test
    public void testOptional() {
        String strArr[] = {"sada", null, ""};
        for (String s : strArr) {
            System.out.println(Optional.ofNullable(s).orElse("").length());
        }
    }

    @Test
    public void test() {
        User user = new User();
        Optional<User> optional = Optional.ofNullable(user);
        System.out.println(!optional.isPresent());
        optional.isPresent();
    }
}
